package org.vincent.ribbon;

import com.netflix.loadbalancer.Server;

public class CustomServer extends Server {

    private final MetaInfo metaInfo;

    public CustomServer(Instance instance) {
        super(instance.getIp(), instance.getPort());
        this.metaInfo = new MetaInfo() {
            @Override
            public String getAppName() {
                return instance.getServiceName();
            }

            @Override
            public String getServerGroup() {
                return instance.getServerGroup();
            }

            @Override
            public String getServiceIdForDiscovery() {
                return instance.getServiceId();
            }

            @Override
            public String getInstanceId() {
                return instance.getInstanceId();
            }
        };
    }

    @Override
    public MetaInfo getMetaInfo() {
        return metaInfo;
    }
}
